package com.example.jwt.framework.security.context;

import org.springframework.security.core.Authentication;

/**
 * @version 1.0.0
 * @className: AuthenticationContextHolder
 * @description: 身份验证信息
 * @author: LiJunYi
 * @create: 2023/4/27 8:59
 */
public class AuthenticationContextHolder {
    private static final ThreadLocal<Authentication> CONTEXT_HOLDER = new ThreadLocal<>();

    public static Authentication getContext()
    {
        return CONTEXT_HOLDER.get();
    }

    public static void setContext(Authentication context)
    {
        CONTEXT_HOLDER.set(context);
    }

    public static void clearContext()
    {
        CONTEXT_HOLDER.remove();
    }
}
